home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr11 / pdox693.zip / TI131.ASC < prev    next >
Text File  |  1992-09-14  |  9KB  |  265 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  Paradox                                NUMBER  :  131
  9.   VERSION  :  All
  10.        OS  :  DOS
  11.      DATE  :  September 14, 1992                       PAGE  :  1/4
  12.  
  13.     TITLE  :  Preventing Users From Accidentally Deleting Records
  14.  
  15.  
  16.  
  17.  
  18.   Intended Audience:
  19.   A moderate level of Paradox knowledge.
  20.  
  21.   Prerequisites:
  22.   Previous experience in writing PAL code is helpful.
  23.  
  24.   Purpose:
  25.   This Technical Information sheet illustrates how you can use a
  26.   PAL script to prevent users from accidentally deleting records.
  27.  
  28.   Paradox allows users to easily delete records from a table.  Some
  29.   users, though, may prefer to have Paradox verify that a specific
  30.   record should be deleted.  This can be quickly accomplished with
  31.   a small PAL script and an adjustment to the way Paradox handles
  32.   the <Delete> key.
  33.  
  34.   While this verification process is easy to add, it can seem
  35.   difficult to those with a limited exposure to Paradox.  Before
  36.   attempting the techniques discussed here, please make sure you
  37.   are familiar with the following concepts:
  38.  
  39.       -  PAL scripts.  Users should know what a PAL script is and
  40.          how to write and edit one.  See the first few chapters of
  41.          the PAL Reference Guide for information about creating and
  42.          using scripts (for versions earlier than 4.0, see the PAL
  43.          User's Guide).  It would also be useful to know how PAL
  44.          works with variables, though this is not required.
  45.  
  46.       -  Network users should also be familiar with Paradox's use
  47.          of private directories and the INIT script.  Private
  48.          directories are covered in the Network Installation Guide
  49.          (for versions earlier than 4.0, see the Network
  50.          Administrator's Guide) and the INIT script is discussed in
  51.          Chapter 7 of the PAL Programmer's Guide (for versions
  52.          earlier than 4.0, see the PAL User's Guide).
  53.  
  54.   Once the verification process is set up, it is simple to use.
  55.   The only person who needs a basic understanding of the above
  56.   concepts is the one implementing it.
  57.  
  58.   Installing the process requires two steps.  First, you will need
  59.   a PAL script that makes certain the record should be deleted by
  60.   allowing the user to verify the deletion or cancel the operation.
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.   PRODUCT  :  Paradox                                NUMBER  :  131
  75.   VERSION  :  All
  76.        OS  :  DOS
  77.      DATE  :  September 14, 1992                       PAGE  :  2/4
  78.  
  79.     TITLE  :  Preventing Users From Accidentally Deleting Records
  80.  
  81.  
  82.  
  83.  
  84.   The following script shows one example of how this can be
  85.   accomplished.
  86.  
  87.        CMode = Sysmode()
  88.        If (not (IsFieldView())) and (CMode = "Edit" or
  89.           CMode = "CoEdit" or CMode = "DataEntry") Then
  90.           Showmenu
  91.              "Cancel" : "Oops, do NOT remove this record.",
  92.              "Ok" : "Yes, PERMANENTLY delete this record."
  93.           Default "Cancel" to DelRec
  94.           If (Retval) and (DelRec = "Ok") Then
  95.              Del
  96.           Endif
  97.        Else
  98.           Del
  99.        Endif
  100.        Release Vars CMode, DelRec
  101.  
  102.   To actually delete a record with this script while Paradox is in
  103.   an appropriate mode, the user must press <Delete> and then select
  104.   Ok from the menu that appears.  If the user presses <Delete>
  105.   accidentally,  selecting Cancel or pressing <Esc> returns the
  106.   user to the table without deleting the current record.
  107.  
  108.   To create this script, use the following process:
  109.  
  110.       -  First, load Paradox and change to the directory where
  111.          Paradox is installed with the Tools | More | Directory
  112.          command.  The default directory for Paradox 4.0 is
  113.          C:\PDOX40.
  114.  
  115.       -  Next, select Scripts | Editor | New (for versions earlier
  116.          than 4.0, select Write instead of New).  When the "Name:"
  117.          prompt appears, type DELREC and press <Enter>.
  118.  
  119.       -  When the Script Editor screen appears, type in the script
  120.          exactly as it appears above.
  121.  
  122.       -  After you have typed the script into the Script Editor,
  123.          press <F2>.  Your DELREC script will be saved.
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.   PRODUCT  :  Paradox                                NUMBER  :  131
  141.   VERSION  :  All
  142.        OS  :  DOS
  143.      DATE  :  September 14, 1992                       PAGE  :  3/4
  144.  
  145.     TITLE  :  Preventing Users From Accidentally Deleting Records
  146.  
  147.  
  148.  
  149.  
  150.   The second part of this process actually "adds" the feature to
  151.   Paradox and can take one of two forms.  Perhaps the quickest way
  152.   to do this is to press <Alt-F10>, select Miniscript, type:
  153.  
  154.             SETKEY -83 PLAY "C:\\PDOX40\\DELREC"
  155.  
  156.   and then press <Enter>.  This tells Paradox to play the DELREC
  157.   script every time the <Delete> key is pressed.
  158.  
  159.   If your copy of Paradox is located in a different directory, be
  160.   sure to change the C:\\PDOX40\\ part of the SETKEY command to
  161.   reflect the actual directory where Paradox is installed.  (Make
  162.   certain you use two "back-slashes" (\\) to separate the various
  163.   branches of the directory name.)
  164.  
  165.   The Miniscript approach is a good way to test your new script,
  166.   for it immediately changes the behavior of the <Delete> key.
  167.   There is a drawback, though.  The new definition only stays in
  168.   effect until you exit Paradox.
  169.  
  170.   To have this feature "permanently" added to your installed copy
  171.   of Paradox, include the above line to your INIT script located in
  172.   the directory where Paradox is installed.  The INIT script is
  173.   analogous to the DOS AUTOEXEC.BAT file; that is, Paradox
  174.   automatically looks for (and executes) the INIT script every time
  175.   the program starts.  Network users will need to have an INIT
  176.   script located in their private directories; that is, the
  177.   directory where their personalized PARADOX.CFG file is located.
  178.  
  179.   To change an existing INIT script, select Scripts | Editor | Open
  180.   (for versions earlier than 4.0, select Edit instead of Open) from
  181.   the main Paradox menu.  If you get an error message similar to
  182.   "Cannot find INIT script", you may not have an INIT script and
  183.   you should use Scripts | Editor | New to create one (for versions
  184.   earlier than 4.0, use Write instead of New).  Be sure to change
  185.   to the proper directory before creating the INIT script.
  186.  
  187.   There are other ways to design the DELREC script.  The one given
  188.   earlier is not the only way to approach the process, although it
  189.   does follow good programming rules.  It makes certain the user is
  190.   in a mode where records can be deleted, allows the user to press
  191.   the <Esc> key during the menu and "cleans up after itself" by
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.   PRODUCT  :  Paradox                                NUMBER  :  131
  207.   VERSION  :  All
  208.        OS  :  DOS
  209.      DATE  :  September 14, 1992                       PAGE  :  4/4
  210.  
  211.     TITLE  :  Preventing Users From Accidentally Deleting Records
  212.  
  213.  
  214.  
  215.  
  216.   clearing the variables it defines.  An alternate approach for
  217.   DELREC might be:
  218.  
  219.        @ 0,0
  220.        ?? "Delete this record? (Y/N):  "
  221.        Accept "A1" Picture "{Y,N}" Default "N" Required To DelRec
  222.        If DelRec = "Y" Then
  223.           Del
  224.        Endif
  225.  
  226.   This example is not as detailed as the earlier one, but it can be
  227.   just as effective.  It also does less error checking, potentially
  228.   making life more difficult for the average user.  Still, with a
  229.   little work, it could be as useful as the first example script.
  230.  
  231.   If this second approach is used for DELREC, the user will have to
  232.   press the <Delete> key, hit <Backspace> to delete the default "N"
  233.   value which appears in the upper left corner of the screen, type
  234.   Y and finally press <Enter> before the record will be erased.
  235.  
  236.   As you can see, PAL allows you to approach a specific problem
  237.   from different directions.  The PAL Reference Guide describes the
  238.   syntax and use of each command and function used in the two
  239.   example scripts (for versions earlier than 4.0 see the PAL User's
  240.   Guide).  It is a good resource for any questions you might have
  241.   along these lines.  Feel free to experiment with different
  242.   variations of these examples (or to create your own approach).
  243.   Make certain, though, to make backups of any data files you
  244.   experiment with.
  245.  
  246.   DISCLAIMER: You have the right to use this technical information
  247.   subject to the terms of the No-Nonsense License Statement that
  248.   you received with the Borland product to which this information
  249.   pertains.
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.